package com.hcj.example.controller;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;

/**
 * 需授权，拿access_token后，才能够访问
 */
@RestController
@RequestMapping("/api")
public class ApiController {
    @RequestMapping("select")
    public String select(){
        SecurityContext context = SecurityContextHolder.getContext();
        Authentication authentication = context.getAuthentication();
        return "hello api OAuth2: select ";
    }

    @RequestMapping("all")
    public String all(){
        return "hello api OAuth2: all ";
    }

    @RequestMapping("read")
    public String read(){
        return "hello api OAuth2: read ";
    }

    @RequestMapping("write")
    public String write(){
        return "hello api OAuth2: write ";
    }
}
